//
//  Particle.m
//  MultiTouch
//
//  Created by iD Student on 7/9/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "Particle.h"
#import "ViewController.h"

@implementation Particle
@synthesize image, lifetime, velocityX, velocityY;

- (id) init:(UIImage *)imageNamed
{
    image = [[UIImageView alloc] initWithImage:imageNamed];
    image.frame = CGRectMake(160, 240, 40, 40);
    velocityX = 0;
    velocityY = 0;
    lifetime = 0;
    return self;
}
- (BOOL) isAlive
{
    return lifetime > 0;
    
}

- (void) update:(UIImage *)imageNamed
    {
        if(imageNamed == [UIImage imageNamed:@"ball.png"])
        {
            lifetime--;
            image.center = CGPointMake(image.center.x + velocityX, image.center.y + velocityY);
        } else {
            lifetime--;
            image.center = CGPointMake(image.center.x + 2*velocityX, image.center.y + 2*velocityY);
        }
    }
            


@end
